package com.tmt.im.common.pojo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.tmt.im.common.annotation._AllowUpdate;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import org.apache.ignite.cache.query.annotations.QuerySqlField;

import java.io.Serial;
import java.sql.Timestamp;

/**
 * 聊天记录PoJo对象
 *
 * @Description TODO
 * @Author wuyi
 * @Date 2024/8/7 15:07
 * @Version 1.0
 **/
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class ChatDataPoJo implements IGetKey<ChatDataKey> {

    @Serial
    private static final long serialVersionUID = -4903179860567906648L;

    public static final String CACHE_NAME = "chat_session_data";

    @QuerySqlField(name = "id", index = true)
    private Long id;

    @QuerySqlField(name = "id", index = true, descending = true)
    private Long mid;

    @QuerySqlField(name = "session_id")
    private Long sessionId;

    @QuerySqlField(name = "creator_id")
    private Long creatorId;

    @QuerySqlField(name = "type")
    private String type;

    @QuerySqlField(name = "content")
    private String content;

    /**
     * 本条信息是针对referenceId这条信息的回复信息
     * 允许为null
     */
    @QuerySqlField(name = "reference_id")
    private Long referenceId;

    @QuerySqlField(name = "create_time", index = true)
    private Timestamp createTime;

    @QuerySqlField(name = "deleted")
    @_AllowUpdate
    private boolean deleted;

    @QuerySqlField(name = "delete_time")
    @_AllowUpdate
    private Timestamp deleteTime;

    @JsonIgnore
    private boolean insert = true;

    @Override
    public ChatDataKey getKey() {
        return new ChatDataKey(id, sessionId);
    }

}
